package Web;

import Entity.User;
import Service.UserService;
import Service.impl.UserServiceimpl;

import javax.servlet.http.HttpServlet;
import java.io.IOException;
public class LoginServlet extends HttpServlet {
    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        String username = request.getParameter("username");
        String pwd = request.getParameter("pwd");
        UserService user = new UserServiceimpl();
        User user1 = new User();
        user1.setName(username);
        user1.setPassword(pwd);
        User Userlogin = user.Login(user1);
        if (Userlogin!=null){
            request.getRequestDispatcher("class1.jsp").forward(request,response);
            return;
        }else {
            response.sendRedirect("index.jsp");
        }
    }

    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {

    }
}
